// RouteNetClientDlg.h : header file
//

#if !defined(AFX_ROUTENETCLIENTDLG_H__674B6AB9_D40D_45E7_83B9_CAAB2B6E405F__INCLUDED_)
#define AFX_ROUTENETCLIENTDLG_H__674B6AB9_D40D_45E7_83B9_CAAB2B6E405F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "route_net_c_serve.h"
#include "ui_route_net_c_serve.h"

#define WM_NET_MSG WM_USER + 1 
#define WM_UI_NET_MSG WM_USER + 2
#define WM_RESPONSE_MSG WM_USER + 3

#include "McMsg_route_net_c.h"
#include "McMsg_ui_route_net_c.h"

/////////////////////////////////////////////////////////////////////////////
// CRouteNetClientDlg dialog
class CRouteNetClientApp;

class CRouteNetClientDlg : public CDialog
{
	friend class McMsg_route_net_c;
	friend class McMsg_ui_route_net_c;
	
// Construction
public:
	CRouteNetClientDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CRouteNetClientDlg)
	enum { IDD = IDD_NETSTRUCT_DIALOG };
	CTreeCtrl	m_treeNet;
	McSortListCtrl	m_listSubnet;
	CEdit	m_editAddr;
	CEdit	m_editAddr2;
	CButton	m_btnModifyConnectString;
	CButton	m_btnEnableNet;
	CButton	m_btnDeleteNet;
	CButton	m_btnConnect;
	CButton	m_btnAddNet;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CRouteNetClientDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CRouteNetClientDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnButtonAddSubnet();
	afx_msg void OnButtonConnect();
	afx_msg void OnButtonDeleteSubnet();
	afx_msg void OnButtonEnableConnect();
	afx_msg void OnButtonModifyConnectstring();
	afx_msg void OnItemchangedList(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDestroy();
	//}}AFX_MSG
	afx_msg LRESULT OnNetMsg(WPARAM wparam, LPARAM lparam);
	afx_msg LRESULT OnUiNetMsg(WPARAM wparam, LPARAM lparam);
	afx_msg LRESULT OnResponseMsg(WPARAM wparam, LPARAM lparam);
	
	DECLARE_MESSAGE_MAP()
private:
	MessageBuffer_Command_route_net_c buffer_route_net_c_;
	MessageBuffer_Command_ui_route_net_c buffer_ui_route_net_c_;
	McMsg_route_net_c msg_route_net_c_;
	McMsg_ui_route_net_c msg_ui_route_net_c_;

	map<long, HTREEITEM> nodeId2hTreeItemMap_;
	map<HTREEITEM, long> hTreeItem2NodeIdMap_;
	long selected_netid_of_treeitem_;
	long selected_netid_of_listitem_;

private:
	void disable_net_item_maintain_button();		
	bool connect_i(bool bConnect);
	void update_maintain_button_4_selected_net_item(long index);

	bool bConnect_;
	bool bConnected_;
	CImageList image_list_;
	MsAddr peerAddr_;
	MsAddr uiPeerAddr_;
public:
	void delete_subnet(bool bForce);
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_ROUTENETCLIENTDLG_H__674B6AB9_D40D_45E7_83B9_CAAB2B6E405F__INCLUDED_)
